<template>
  <div id="container"></div>
</template>

<script setup>
import { onMounted, onUnmounted } from "vue";
import { Chart } from "@antv/g2";

let chart;

onMounted(() => {
  chart = new Chart({
    container,
    autoFit: true,
  });
  chart
    .title('固定宽度圆角条形图')
    .interval()
    .data([
    { name: "MODIFY", value: 138, washaway: 0.21014492753623193 },
    { name: "PRERELEASE", value: 109, washaway: 0.5596330275229358 },
    { name: "RELEASING", value: 48, washaway: 0 },
  ])
  .encode('x', 'name')
  .encode('y', 'value')
  .encode('color', 'name')
  .encode('size', 80)
  .style('radiusTopLeft', 10)
  .style('radiusTopRight', 20)
  .style('radiusBottomLeft', 40)
  .style('radiusBottomRight', 30)

  chart.render();
});

// 销毁
onUnmounted(() => {
  chart.destroy();
  chart = null;
});
</script>

<style lang="less" scoped>
#container {
  width: 800px;
  height: 400px;
}
</style>
